
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>使用目标三元组描述目标平台 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="part2.html" />
    
    
    <link rel="prev" href="introduction.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter0/introduction.html">
            
                <a href="../chapter0/introduction.html">
            
                    
                    第零章：实验环境说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter1/introduction.html">
            
                <a href="../chapter1/introduction.html">
            
                    
                    第一章：独立式可执行程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter1/part1.html">
            
                <a href="../chapter1/part1.html">
            
                    
                    [安装 nightly rust]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter1/part2.html">
            
                <a href="../chapter1/part2.html">
            
                    
                    使用包管理器 cargo 创建 rust binary 项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter1/part3.html">
            
                <a href="../chapter1/part3.html">
            
                    
                    移除标准库依赖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter1/part4.html">
            
                <a href="../chapter1/part4.html">
            
                    
                    [移除 runtime 依赖]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter1/part5.html">
            
                <a href="../chapter1/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="introduction.html">
            
                <a href="introduction.html">
            
                    
                    第二章：最小化内核
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.4.1" data-path="part1.html">
            
                <a href="part1.html">
            
                    
                    使用目标三元组描述目标平台
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="part2.html">
            
                <a href="part2.html">
            
                    
                    编译、生成内核镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="part3.html">
            
                <a href="part3.html">
            
                    
                    使用链接脚本指定内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="part4.html">
            
                <a href="part4.html">
            
                    
                    [重写程序入口点 -start]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="part5.html">
            
                <a href="part5.html">
            
                    
                    [使用 Qemu 运行内核]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="part6.html">
            
                <a href="part6.html">
            
                    
                    封装 SBI 接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="part7.html">
            
                <a href="part7.html">
            
                    
                    [实现格式化输出]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="part8.html">
            
                <a href="part8.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter3/introduction.html">
            
                <a href="../chapter3/introduction.html">
            
                    
                    第三章：中断
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter3/part1.html">
            
                <a href="../chapter3/part1.html">
            
                    
                    rv64 中断介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter3/part2.html">
            
                <a href="../chapter3/part2.html">
            
                    
                    [手动触发断点中断]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter3/part3.html">
            
                <a href="../chapter3/part3.html">
            
                    
                    程序运行上下文环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter3/part4.html">
            
                <a href="../chapter3/part4.html">
            
                    
                    [实现上下文环境保存与恢复]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter3/part5.html">
            
                <a href="../chapter3/part5.html">
            
                    
                    [时钟中断]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../chapter3/part6.html">
            
                <a href="../chapter3/part6.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter4/introduction.html">
            
                <a href="../chapter4/introduction.html">
            
                    
                    第四章：内存管理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter4/part1.html">
            
                <a href="../chapter4/part1.html">
            
                    
                    [物理内存探测与管理]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter4/part2.html">
            
                <a href="../chapter4/part2.html">
            
                    
                    [动态内存分配]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter4/part3.html">
            
                <a href="../chapter4/part3.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter5/introduction.html">
            
                <a href="../chapter5/introduction.html">
            
                    
                    第五章：内存虚拟化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter5/part1.html">
            
                <a href="../chapter5/part1.html">
            
                    
                    页表：从虚拟内存到物理内存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter5/part2.html">
            
                <a href="../chapter5/part2.html">
            
                    
                    [内核初始映射]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter5/part3.html">
            
                <a href="../chapter5/part3.html">
            
                    
                    内核重映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter5/part4.html">
            
                <a href="../chapter5/part4.html">
            
                    
                    内核重映射实现之一：页表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter5/part5.html">
            
                <a href="../chapter5/part5.html">
            
                    
                    内核重映射实现之二：MemorySet
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter5/part6.html">
            
                <a href="../chapter5/part6.html">
            
                    
                    [内核重映射实现之三：完结]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../chapter5/part7.html">
            
                <a href="../chapter5/part7.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter6/introduction.html">
            
                <a href="../chapter6/introduction.html">
            
                    
                    第六章：内核线程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter6/part1.html">
            
                <a href="../chapter6/part1.html">
            
                    
                    线程状态与保存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter6/part2.html">
            
                <a href="../chapter6/part2.html">
            
                    
                    线程切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter6/part3.html">
            
                <a href="../chapter6/part3.html">
            
                    
                    内核线程初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../chapter6/part4.html">
            
                <a href="../chapter6/part4.html">
            
                    
                    [内核线程创建与切换测试]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../chapter6/part5.html">
            
                <a href="../chapter6/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter7/introduction.html">
            
                <a href="../chapter7/introduction.html">
            
                    
                    第七章：线程调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter7/part1.html">
            
                <a href="../chapter7/part1.html">
            
                    
                    线程池与线程管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter7/part2.html">
            
                <a href="../chapter7/part2.html">
            
                    
                    内核调度线程 idle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter7/part3.html">
            
                <a href="../chapter7/part3.html">
            
                    
                    线程调度之 Round Robin 算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../chapter7/part4.html">
            
                <a href="../chapter7/part4.html">
            
                    
                    [线程调度测试]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../chapter7/part5.html">
            
                <a href="../chapter7/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter8/introduction.html">
            
                <a href="../chapter8/introduction.html">
            
                    
                    第八章：进程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter8/part1.html">
            
                <a href="../chapter8/part1.html">
            
                    
                    [编写用户程序]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter8/part1_1.html">
            
                <a href="../chapter8/part1_1.html">
            
                    
                    合并内核与应用程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter8/part2.html">
            
                <a href="../chapter8/part2.html">
            
                    
                    在内核中实现系统调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter8/part3.html">
            
                <a href="../chapter8/part3.html">
            
                    
                    创建虚拟内存空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter8/part4.html">
            
                <a href="../chapter8/part4.html">
            
                    
                    [创建进程]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../chapter8/part5.html">
            
                <a href="../chapter8/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter9/introduction.html">
            
                <a href="../chapter9/introduction.html">
            
                    
                    第九章：文件系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter9/part1.html">
            
                <a href="../chapter9/part1.html">
            
                    
                    [使用文件系统]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter9/part2.html">
            
                <a href="../chapter9/part2.html">
            
                    
                    [实现记事本]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter9/part3.html">
            
                <a href="../chapter9/part3.html">
            
                    
                    [实现终端]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter9/part4.html">
            
                <a href="../chapter9/part4.html">
            
                    
                    [文件读写]
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter9/part5.html">
            
                <a href="../chapter9/part5.html">
            
                    
                    总结与展望
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter10/introduction.html">
            
                <a href="../chapter10/introduction.html">
            
                    
                    第十章：同步互斥
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../exercise/introduction.html">
            
                <a href="../exercise/introduction.html">
            
                    
                    练习题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../exercise/part1.html">
            
                <a href="../exercise/part1.html">
            
                    
                    1. 中断异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../exercise/part2.html">
            
                <a href="../exercise/part2.html">
            
                    
                    2. 物理内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../exercise/part3.html">
            
                <a href="../exercise/part3.html">
            
                    
                    3. 虚拟内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../exercise/part4.html">
            
                <a href="../exercise/part4.html">
            
                    
                    4. 线程管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../exercise/part5.html">
            
                <a href="../exercise/part5.html">
            
                    
                    5. 用户进程（+ 虚拟内存管理 + 线程管理）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../exercise/part6.html">
            
                <a href="../exercise/part6.html">
            
                    
                    6. CPU 调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../exercise/part7.html">
            
                <a href="../exercise/part7.html">
            
                    
                    7. 同步互斥
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../exercise/part8.html">
            
                <a href="../exercise/part8.html">
            
                    
                    8. 文件系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../appendix/introduction.html">
            
                <a href="../appendix/introduction.html">
            
                    
                    附录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../appendix/inline_asm.html">
            
                <a href="../appendix/inline_asm.html">
            
                    
                    内联汇编
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../appendix/install_rust.html">
            
                <a href="../appendix/install_rust.html">
            
                    
                    安装 rust
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >使用目标三元组描述目标平台</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x4F7F;&#x7528;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#x63CF;&#x8FF0;&#x76EE;&#x6807;&#x5E73;&#x53F0;">&#x4F7F;&#x7528;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#x63CF;&#x8FF0;&#x76EE;&#x6807;&#x5E73;&#x53F0;</h2>
<ul>
<li><a href="https://github.com/rcore-os/rCore_tutorial/tree/ch2-pa4" target="_blank">&#x4EE3;&#x7801;</a></li>
</ul>
<p>cargo &#x5728;&#x7F16;&#x8BD1;&#x9879;&#x76EE;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x9644;&#x52A0;&#x76EE;&#x6807;&#x53C2;&#x6570; <code>--target <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>target</span> <span class="token attr-name">triple</span><span class="token punctuation">&gt;</span></span></code> &#x8BBE;&#x7F6E;&#x9879;&#x76EE;&#x7684;&#x76EE;&#x6807;&#x5E73;&#x53F0;&#x3002;&#x5E73;&#x53F0;&#x5305;&#x62EC;&#x786C;&#x4EF6;&#x548C;&#x8F6F;&#x4EF6;&#x652F;&#x6301;&#xFF0C;&#x4E8B;&#x5B9E;&#x4E0A;&#xFF0C;<strong>&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#xFF08;target triple&#xFF09;</strong> &#x5305;&#x542B;&#xFF1A;cpu &#x67B6;&#x6784;&#x3001;&#x4F9B;&#x5E94;&#x5546;&#x3001;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x548C; <a href="https://stackoverflow.com/questions/2171177/what-is-an-application-binary-interface-abi/2456882#2456882" target="_blank">ABI</a> &#x3002;</p>
<p>&#x5B89;&#x88C5; Rust &#x65F6;&#xFF0C;&#x9ED8;&#x8BA4;&#x7F16;&#x8BD1;&#x540E;&#x7684;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x8981;&#x5728;&#x672C;&#x5E73;&#x53F0;&#x4E0A;&#x6267;&#x884C;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;</p>
<p><code>rustc --version --verbose</code> &#x6765;&#x67E5;&#x770B; Rust &#x7684;&#x9ED8;&#x8BA4;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#xFF1A;</p>
<pre class="language-"><code class="lang-sh">$ rustc --version --verbose
rustc <span class="token number">1.42</span>.0-nightly <span class="token punctuation">(</span><span class="token number">859764425</span> <span class="token number">2020</span>-01-07<span class="token punctuation">)</span>
binary: rustc
commit-hash: 85976442558bf2d09cec3aa49c9c9ba86fb15c1f
commit-date: <span class="token number">2020</span>-01-07
host: x86_64-unknown-linux-gnu
release: <span class="token number">1.42</span>.0-nightly
LLVM version: <span class="token number">9.0</span>
</code></pre>
<p>&#x5728; <code>host</code> &#x5904;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x9ED8;&#x8BA4;&#x7684;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#xFF0C; cpu &#x67B6;&#x6784;&#x4E3A; <code>x86_64</code> &#xFF0C;&#x4F9B;&#x5E94;&#x5546;&#x4E3A; <code>unknown</code> &#xFF0C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E3A; <code>linux</code> &#xFF0C;ABI &#x4E3A; <code>gnu</code> &#x3002;&#x7531;&#x4E8E;&#x6211;&#x4EEC;&#x662F;&#x5728; 64 &#x4F4D; ubuntu &#x4E0A;&#x5B89;&#x88C5;&#x7684; Rust &#xFF0C;&#x8FD9;&#x4E2A;&#x9ED8;&#x8BA4;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#x7684;&#x786E;&#x63CF;&#x8FF0;&#x4E86;&#x672C;&#x5E73;&#x53F0;&#x3002;</p>
<p>&#x5B98;&#x65B9;&#x5BF9;&#x4E00;&#x4E9B;&#x5E73;&#x53F0;&#x63D0;&#x4F9B;&#x4E86;&#x9ED8;&#x8BA4;&#x7684;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x6765;&#x67E5;&#x770B;&#x5B8C;&#x6574;&#x5217;&#x8868;&#xFF1A;</p>
<pre class="language-"><code class="lang-sh">$ rustc --print target-list
</code></pre>
<h3 id="&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;-json-&#x63CF;&#x8FF0;&#x6587;&#x4EF6;">&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4; JSON &#x63CF;&#x8FF0;&#x6587;&#x4EF6;</h3>
<p>&#x9664;&#x4E86;&#x9ED8;&#x8BA4;&#x63D0;&#x4F9B;&#x7684;&#x4EE5;&#x5916;&#xFF0C;Rust &#x4E5F;&#x5141;&#x8BB8;&#x6211;&#x4EEC;&#x7528; JSON &#x6587;&#x4EF6;&#x5B9A;&#x4E49;&#x81EA;&#x5DF1;&#x7684;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#x3002;</p>
<p>&#x9996;&#x5148;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x4E00;&#x4E0B;&#x9ED8;&#x8BA4;&#x7684;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4; <strong>x86_64-unknown-linux-gnu</strong> &#x7684; <strong>JSON</strong> &#x6587;&#x4EF6;&#x63CF;&#x8FF0;&#xFF0C;&#x8F93;&#x5165;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre class="language-"><code class="lang-sh">$ rustc -Z unstable-options --print target-spec-json --target x86_64-unknown-linux-gnu
</code></pre>
<p>&#x53EF;&#x4EE5;&#x5F97;&#x5230;&#x5982;&#x4E0B;&#x8F93;&#x51FA;&#xFF1A;</p>
<pre class="language-"><code class="lang-json"><span class="token comment">// x86_64-unknown-linux-gnu.json</span>
<span class="token punctuation">{</span>
  <span class="token property">&quot;arch&quot;</span><span class="token operator">:</span> <span class="token string">&quot;x86_64&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;cpu&quot;</span><span class="token operator">:</span> <span class="token string">&quot;x86-64&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;data-layout&quot;</span><span class="token operator">:</span> <span class="token string">&quot;e-m:e-i64:64-f80:128-n8:16:32:64-S128&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;dynamic-linking&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;env&quot;</span><span class="token operator">:</span> <span class="token string">&quot;gnu&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;executables&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;has-elf-tls&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;has-rpath&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;is-builtin&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;linker-flavor&quot;</span><span class="token operator">:</span> <span class="token string">&quot;gcc&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;linker-is-gnu&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;llvm-target&quot;</span><span class="token operator">:</span> <span class="token string">&quot;x86_64-unknown-linux-gnu&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;max-atomic-width&quot;</span><span class="token operator">:</span> <span class="token number">64</span><span class="token punctuation">,</span>
  <span class="token property">&quot;os&quot;</span><span class="token operator">:</span> <span class="token string">&quot;linux&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;position-independent-executables&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;pre-link-args&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;gcc&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&quot;-Wl,--as-needed&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;-Wl,-z,noexecstack&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;-m64&quot;</span><span class="token punctuation">]</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">&quot;relro-level&quot;</span><span class="token operator">:</span> <span class="token string">&quot;full&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;stack-probes&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;target-c-int-width&quot;</span><span class="token operator">:</span> <span class="token string">&quot;32&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;target-endian&quot;</span><span class="token operator">:</span> <span class="token string">&quot;little&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;target-family&quot;</span><span class="token operator">:</span> <span class="token string">&quot;unix&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;target-pointer-width&quot;</span><span class="token operator">:</span> <span class="token string">&quot;64&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;vendor&quot;</span><span class="token operator">:</span> <span class="token string">&quot;unknown&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x91CC;&#x9762;&#x63CF;&#x8FF0;&#x4E86;&#x67B6;&#x6784;&#x3001; CPU &#x3001;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x3001; ABI &#x3001;&#x7AEF;&#x5E8F;&#x3001;&#x5B57;&#x957F;&#x7B49;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x73B0;&#x5728;&#x60F3;&#x57FA;&#x4E8E; 64 &#x4F4D; RISCV &#x67B6;&#x6784;&#x5F00;&#x53D1;&#x5185;&#x6838;&#xFF0C;&#x5C31;&#x9700;&#x8981;&#x4E00;&#x4EFD; <code>riscv64</code> &#x7684;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#x3002;&#x5E78;&#x8FD0;&#x7684;&#x662F;&#xFF0C;&#x76EE;&#x524D; Rust &#x7F16;&#x8BD1;&#x5668;&#x5DF2;&#x7ECF;&#x5185;&#x7F6E;&#x4E86;&#x4E00;&#x4E2A;&#x53EF;&#x7528;&#x7684;&#x76EE;&#x6807;&#xFF1A;<code>riscv64imac-unknown-none-elf</code>&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x67E5;&#x770B;&#x4E00;&#x4E0B;&#x5B83;&#x7684; JSON &#x63CF;&#x8FF0;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre class="language-"><code class="lang-sh">$ rustc -Z unstable-options --print target-spec-json --target riscv64imac-unknown-none-elf
</code></pre>
<pre class="language-"><code class="lang-json"><span class="token comment">// riscv64imac-unknown-none-elf.json</span>
<span class="token punctuation">{</span>
  <span class="token property">&quot;abi-blacklist&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token string">&quot;cdecl&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;stdcall&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;fastcall&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;vectorcall&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;thiscall&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;aapcs&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;win64&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;sysv64&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;ptx-kernel&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;msp430-interrupt&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;x86-interrupt&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;amdgpu-kernel&quot;</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token property">&quot;arch&quot;</span><span class="token operator">:</span> <span class="token string">&quot;riscv64&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;code-model&quot;</span><span class="token operator">:</span> <span class="token string">&quot;medium&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;cpu&quot;</span><span class="token operator">:</span> <span class="token string">&quot;generic-rv64&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;data-layout&quot;</span><span class="token operator">:</span> <span class="token string">&quot;e-m:e-p:64:64-i64:64-i128:128-n64-S128&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;eliminate-frame-pointer&quot;</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
  <span class="token property">&quot;emit-debug-gdb-scripts&quot;</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
  <span class="token property">&quot;env&quot;</span><span class="token operator">:</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;executables&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;features&quot;</span><span class="token operator">:</span> <span class="token string">&quot;+m,+a,+c&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;is-builtin&quot;</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  <span class="token property">&quot;linker&quot;</span><span class="token operator">:</span> <span class="token string">&quot;rust-lld&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;linker-flavor&quot;</span><span class="token operator">:</span> <span class="token string">&quot;ld.lld&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;llvm-target&quot;</span><span class="token operator">:</span> <span class="token string">&quot;riscv64&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;max-atomic-width&quot;</span><span class="token operator">:</span> <span class="token number">64</span><span class="token punctuation">,</span>
  <span class="token property">&quot;os&quot;</span><span class="token operator">:</span> <span class="token string">&quot;none&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;panic-strategy&quot;</span><span class="token operator">:</span> <span class="token string">&quot;abort&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;relocation-model&quot;</span><span class="token operator">:</span> <span class="token string">&quot;static&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;target-c-int-width&quot;</span><span class="token operator">:</span> <span class="token string">&quot;32&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;target-endian&quot;</span><span class="token operator">:</span> <span class="token string">&quot;little&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;target-pointer-width&quot;</span><span class="token operator">:</span> <span class="token string">&quot;64&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;vendor&quot;</span><span class="token operator">:</span> <span class="token string">&quot;unknown&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x6765;&#x770B;&#x5B83;&#x4E0E;&#x9ED8;&#x8BA4;&#x7684;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#x6709;&#x7740;&#x4E9B;&#x8BB8;&#x4E0D;&#x540C;&#x7684;&#x5730;&#x65B9;&#xFF1A;</p>
<pre class="language-"><code class="lang-json"><span class="token property">&quot;panic-strategy&quot;</span><span class="token operator">:</span> <span class="token string">&quot;abort&quot;</span><span class="token punctuation">,</span>
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x63CF;&#x8FF0;&#x4E86; <code>panic</code> &#x65F6;&#x91C7;&#x53D6;&#x7684;&#x7B56;&#x7565;&#x3002;&#x56DE;&#x5FC6;&#x4E0A;&#x4E00;&#x7AE0;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5728; <code>Cargo.toml</code> &#x4E2D;&#x8BBE;&#x7F6E;&#x7A0B;&#x5E8F;&#x5728; <code>panic</code> &#x65F6;&#x76F4;&#x63A5; <code>abort</code> &#xFF0C;&#x4ECE;&#x800C;&#x4E0D;&#x5FC5;&#x8C03;&#x7528;&#x5806;&#x6808;&#x5C55;&#x5F00;&#x5904;&#x7406;&#x51FD;&#x6570;&#x3002;&#x7531;&#x4E8E;&#x76EE;&#x6807;&#x4E09;&#x5143;&#x7EC4;&#x4E2D;&#x5DF2;&#x7ECF;&#x5305;&#x542B;&#x4E86;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5C06; <code>Cargo.toml</code> &#x4E2D;&#x7684;&#x8BBE;&#x7F6E;&#x5220;&#x9664;&#x4E86;&#xFF1A;</p>
<pre class="language-"><code class="lang-diff"><span class="token deleted-sign deleted"><span class="token prefix deleted">-</span><span class="token line">[profile.dev]
</span><span class="token prefix deleted">-</span><span class="token line">panic = &quot;abort&quot;
</span></span>
<span class="token deleted-sign deleted"><span class="token prefix deleted">-</span><span class="token line">[profile.release]
</span><span class="token prefix deleted">-</span><span class="token line">panic = &quot;abort&quot;
</span></span></code></pre>
<p><div id="page-footer" class="localized-footer"><hr><p><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css"></p>
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
  var gitalk = new Gitalk({
    clientID: "ab871063a9fa7f1da571",
    clientSecret: "4760b384e3e452d2241d859cfa6a7da21a8729ec",
    repo: "rCore_tutorial_doc",
    owner: "rcore-os",
    admin: [
      "chyyuu",
      "xyongcn",
      "wangrunji0408",
      "xy-plus",
      "PanQL",
      "wyfcyx",
      "equation314"
    ],
    id: location.pathname,
    distractionFreeMode: false
  });
  gitalk.render("gitalk-container");
</script>
</div></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="introduction.html" class="navigation navigation-prev " aria-label="Previous page: 第二章：最小化内核">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="part2.html" class="navigation navigation-next " aria-label="Next page: 编译、生成内核镜像">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"使用目标三元组描述目标平台","level":"1.4.1","depth":2,"next":{"title":"编译、生成内核镜像","level":"1.4.2","depth":2,"path":"chapter2/part2.md","ref":"chapter2/part2.md","articles":[]},"previous":{"title":"第二章：最小化内核","level":"1.4","depth":1,"path":"chapter2/introduction.md","ref":"chapter2/introduction.md","articles":[{"title":"使用目标三元组描述目标平台","level":"1.4.1","depth":2,"path":"chapter2/part1.md","ref":"chapter2/part1.md","articles":[]},{"title":"编译、生成内核镜像","level":"1.4.2","depth":2,"path":"chapter2/part2.md","ref":"chapter2/part2.md","articles":[]},{"title":"使用链接脚本指定内存布局","level":"1.4.3","depth":2,"path":"chapter2/part3.md","ref":"chapter2/part3.md","articles":[]},{"title":"[重写程序入口点 -start]","level":"1.4.4","depth":2,"path":"chapter2/part4.md","ref":"chapter2/part4.md","articles":[]},{"title":"[使用 Qemu 运行内核]","level":"1.4.5","depth":2,"path":"chapter2/part5.md","ref":"chapter2/part5.md","articles":[]},{"title":"封装 SBI 接口","level":"1.4.6","depth":2,"path":"chapter2/part6.md","ref":"chapter2/part6.md","articles":[]},{"title":"[实现格式化输出]","level":"1.4.7","depth":2,"path":"chapter2/part7.md","ref":"chapter2/part7.md","articles":[]},{"title":"总结与展望","level":"1.4.8","depth":2,"path":"chapter2/part8.md","ref":"chapter2/part8.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["hide-element","chapter-fold","katex","alerts","emphasize","-highlight","prism","localized-footer","mermaid-gb3"],"pluginsConfig":{"chapter-fold":{},"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"emphasize":{},"search":{},"localized-footer":{"filename":"extensions/comment/gitalk.html","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"hide-element":{"elements":[".gitbook-link"]},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"alerts":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter2/part1.md","mtime":"2020-09-09T11:31:56.891Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-09-10T06:57:01.716Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

